import 'package:flutterapp/models/general_type.dart';
import 'package:scoped_model/scoped_model.dart';

//flutter状态管理
class FilterBarModel extends Model {
  List<GeneralType> _roomTypeList = [];
  List<GeneralType> _orientedList = [];
  List<GeneralType> _floorList = [];

  Set<String> _selectedList = Set<String>();

//返回一个方法...... 获取数据的
  Map<String, List<GeneralType>> get dataList {
    var result = Map<String, List<GeneralType>>();
    result['roomTypeList'] = _roomTypeList;
    result['orientedList'] = _orientedList;
    result['floorList'] = _floorList;

    return result;
  }

//设置/修改状态
  set dataList(Map<String, List<GeneralType>> data) {
    _roomTypeList = data['roomTypeList'];
    _orientedList = data['orientedList'];
    _floorList = data['floorList'];

    notifyListeners(); //更新数据
  }

  //获取方法
  Set<String> get selectedList {
    return _selectedList;
  }

  //设置方法
  setSelectedListToggleItem(String data) {
    if (_selectedList.contains(data)) {
      _selectedList.remove(data);
    } else {
      _selectedList.add(data);
    }
    //更新
    notifyListeners();
  }
}
